Don't evaluate positional after_scale aesthetics when building a legend - #1072
Merged
Conversation
Make scale_discrete generic over GuideTypeT instead of hardcoding guide: Literal["legend"] | None, and add OptionalLegend, OptionalColorbar and OptionalGuide aliases to _runtime_typing. Each discrete scale subclass now declares its own guide field. Behavior change: identity scales for color, fill, shape, linetype and alpha now default to guide="legend" (size and stroke keep None). scale_position_discrete declares guide: None as a field instead of assigning it in __post_init__.
Legend key data can only contain the matched legend aesthetics and the geom's default aesthetics. Staged positional aesthetics (e.g. x, y) never appear in it, so evaluating their after_scale expressions against the key data raised a PlotnineError, triggered a spurious "this should not happen" warning, and discarded all legitimate legend modifiers via the fallback path. Filter the modifiers to aesthetics that can be in the key data before evaluation. closes #1067
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1072 +/- ##
==========================================
+ Coverage 87.10% 87.14% +0.04%
==========================================
Files 208 208
Lines 14321 14338 +17
Branches 1788 1788
==========================================
+ Hits 12474 12495 +21
+ Misses 1283 1280 -3
+ Partials 564 563 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.